package org.hzz.promotions.domain.repository;

import io.gitee.pkmer.convention.page.PageResponse;
import io.gitee.pkmer.convention.page.query.PageQuery;
import org.hzz.promotions.domain.entity.ExchangeCodeEntity;
import org.hzz.promotions.types.enums.code.CodeType;

import java.util.List;
import java.util.Optional;

/**
 * @author <a href="mailto:1193094618@qq.com">pkmer</a>
 * <br>
 * <a href = "https://gitee.com/developeros/videos-online">Code Repository</a>
 * At 2024/8/31
 * 兑换码仓储
 */
public interface ExchangeCodeRepository {

    /**
     * 插入兑换码
     * @param entity 兑换码实体
     */
    void insertExchangeCode(ExchangeCodeEntity entity);

    /**
     * 批量插入兑换码
     * @param entities 兑换码实体列表
     */
    void batchInsertExchangeCodes(List<ExchangeCodeEntity> entities);

    /**
     * 根据目标id删除兑换码
     * @param targetId 目标id
     */
    void deleteCouponCodeByTargetId(Long targetId);

    /**
     * 根据兑换码序列号查询兑换码
     * @param serialNum 序列号
     * @param type 兑换码类型
     * @return 兑换码实体
     */
    Optional<ExchangeCodeEntity> selectBySerialNum(int serialNum, CodeType type);


    PageResponse<ExchangeCodeEntity> pageQueryCode(PageQuery pageQuery);

    /**
     * 更新兑换码
     * @param entity 兑换码实体
     */
    void updateExchangeCode(ExchangeCodeEntity entity);
}
